<template>
  <view class="u-page">
    <view class="cell-page">
      <view class="u-page__item">
        <text class="u-page__item__title">状态</text>
        <u-cell-group><u-cell :title="state | formatText"></u-cell></u-cell-group>
      </view>
    </view>
    <view class="cell-page" v-if="state == '4'">
      <view class="u-page__item">
        <text class="u-page__item__title">消息</text>
        <u-cell-group><u-cell :title="reason"></u-cell></u-cell-group>
      </view>
    </view>
    <view class="cell-page" v-if="state == '2'">
      <view class="u-page__item">
        <text class="u-page__item__title">提示</text>
        <u-cell-group><u-cell title="材料审核中，请耐心等待。"></u-cell></u-cell-group>
      </view>
    </view>
    <view class="cell-page" v-if="state == '3'">
      <view class="u-page__item">
        <text class="u-page__item__title">提示</text>
        <u-cell-group><u-cell title="材料审核已通过，近期请留意预留银行卡的收款信息。"></u-cell></u-cell-group>
      </view>
    </view>
    <view class="cell-page" v-if="state == '4'">
      <view class="u-page__item">
        <text class="u-page__item__title">提示</text>
        <u-cell-group><u-cell title="材料审核未通过，请参照未通过'消息',仔细核对后重新上报。"></u-cell></u-cell-group>
      </view>
    </view>
    <u-row class="w-100 mt-4" justify="center" v-if="state == '4'">
      <u-col span="5" justify="center">
        <u-button type="primary" shape="circle" @click="reset"><view>重 填</view></u-button>
      </u-col>
    </u-row>
  </view>
</template>

<script>
import { checkSave, restart } from '@/common/api/yxRegister.js';

export default {
  filters: {
    formatText(text) {
      switch (text) {
        case 1:
          return '未申请';
        case 2:
          return '审核中';
        case 3:
          return '已通过';
        case 4:
          return '未通过';
        case 5:
          return '已领取';
      }
    },
  },
  data() {
    return {
      state: 1,
      reason: '',
      idCard: '',
    };
  },
  onLoad(options) {
    if (options.state) {
      this.state = parseInt(options.state);
    }
    if (options.reason) {
      this.reason = options.reason;
    }
    if (options.idCard) {
      this.idCard = options.idCard;
    }
    if (this.state == 1) {
      let that = this;

      const yxInfo = that.$getYxInfo(that.idCard);
      // checkSave(yxInfo.step3).then(res => {
      //   that.state = res.data.state;
      //   that.reason = res.data.reason;
      // });
	  checkSave({idCardNo: that.idCard}).then(res => {
	    that.state = res.data.state;
	    that.reason = res.data.reason;
	  });
    }
  },
  methods: {
    reset() {
      restart({ idCardNo: this.idCard, state: 1 }).then(res => {
        uni.navigateTo({
          url: '/pages/yx/step1?idCard=' + this.idCard,
        });
      });
    },
  },
};
</script>

<style scoped lang="scss"></style>
